package com.yy.permissions_general.module.system.aopLog.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yy.permissions_general.base.controller.BaseController;
import com.yy.permissions_general.common.aopSubmit.aop.NoRepeatSubmit;
import com.yy.permissions_general.module.system.aopLog.entity.SysLog;
import com.yy.permissions_general.module.system.aopLog.service.SysLogService;
import com.yy.permissions_general.utils.ResultUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * <p>
 * 系统日志表前端控制器
 * </p>
 *
 * @author YY
 * @since 2021-08-04
 */
@RestController
@RequestMapping("/sysLog")
public class SysLogController extends BaseController {

    @Resource
    private SysLogService sysLogService;

    /**
    * 查询列表
    * @param sysLog
    * @param limit
    * @param page
    * @return
    */
    @RequestMapping("/list")
    @NoRepeatSubmit(key="#sysLog.taskType")
    public ResultUtil list(SysLog sysLog, int limit, int page) {
      return ResultUtil.buildPagination(sysLogService.selectPageList(sysLog,limit,page));
    }
    /**
    * @Description: 删除日志
    * @return
    */
    @RequestMapping("/deleteAll")
    @NoRepeatSubmit(key="sysLog.deleteAll")
    @PreAuthorize("hasPermission('/sysLog/deleteAll','sysLog:deleteAll')")
    public ResultUtil deleteAll() {
        this.sysLogService.remove(new QueryWrapper<SysLog>());
        return ResultUtil.success();
    }

}
